import { Injectable } from '@nestjs/common';
import * as exceljs from 'exceljs';
@Injectable()
export class ExcelExportService {
  async exportToExcel(data, columns) {
    const workbook = new exceljs.Workbook();
    const worksheet = workbook.addWorksheet('Data');
    worksheet.columns = columns;
    data.forEach((rowData) => {
      worksheet.addRow(rowData);
    });
    return workbook.xlsx.writeBuffer();
  }
}
